import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import BMap
df= pd.read_excel('2023年某品牌北京地区销售数据.xlsx')
data = df[['分店名','销售额（万元）']].values.tolist()
bMap = BMap(init_opts=opts.InitOpts(
    width='1000px',height='800px',page_title='地理热力图'))
for (name,longitude,latitude) in zip(df['分店名'],df['经度'],df['纬度']):
    bMap.add_coordinate(name,longitude,latitude)
bMap.add_schema(baidu_ak='PmSUNzlvB2wZMLui6vGozZKMKQb1Q5AC',center=[116.379017,39.91667],zoom=11)
bMap.add(series_name='',data_pair=data,type_='heatmap')
bMap.add(series_name='',data_pair=data,
         type_='scatter',symbol_size=0,
         label_opts=opts.LabelOpts(color='rgba(0,0,0,0)')
)
bMap.set_global_opts(
    title_opts=opts.TitleOpts(
        title='2023年某品牌北京各分店销售额地理热力图',
        pos_left='center'),
    legend_opts=opts.LegendOpts(is_show=False),
    visualmap_opts=opts.VisualMapOpts(
        max_=1500,min_=100,pos_top='75%',
        range_color=['green','yellow','red'])
)
bMap.render('bMap_sale.html')